package com.cat.dataStructure03;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/hash-divided-string/
 * @create 2025/11/10 19:37
 * @since JDK17
 */

public class Solution38 {
    public String stringHash(String s, int k) {
        int n = s.length(), m = n / k;
        StringBuilder ans = new StringBuilder();
        for (int i = 0, j = 0; i < m; i++) {
            int h = 0, e = j + k;
            for (; j < e; j++) {
                h += s.charAt(j) - 'a';
            }
            ans.append((char)('a' + (h % 26)));
        }

        return ans.toString();
    }
}
